package com.topnav.mc.uitls;

import com.js.lib.exception.CustomException;
import com.js.lib.result.Result;
import com.topnav.mc.exception.ExceptionMsg;
/**
 * 说明：
 * @类名: ResultUtil
 * <p>
 *
 * </p>
 * @author   kenny
 * @Date	 2021年10月27日下午2:15:13
 */
public class ErrorResultUtil {

	public static Result result(ExceptionMsg em,Object ... args){
		if (em.getCode() == 0){
			return Result.ok(em.getFillDesc(args));
		}else{
			return Result.error(em.getCode(),em.getFillDesc(args));
		}
	}

	public static Result result(ExceptionMsg em){
		return Result.error(em.getCode(),em.getDesc());
	}


	/**
	 *
	 * @param exception CustomException
	 * @return
	 */
	public static Result result(CustomException exception){
		if (exception.getExtendMsg() != null && exception.getExtendMsg().length > 0){
			return Result.error(exception.getCode(),String.format(exception.getMsg(), exception.getExtendMsg()));
		}else{
			return Result.error(exception.getCode(),exception.getMsg());
		}

	}

}
